package com.example.user;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

/**
 * @author wangbin
 */
public interface UserRepository extends JpaRepository<User, Long> {
    /**
     * 通过用户名查询用户
     *
     * @param username 用户名
     * @return 用户实体
     */
    @Query("select u from User u where u.username=:username")
    Optional<User> findFirstByUsername(@Param("username") String username);
}
